/**
 * Copyright (c) Software Institude of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.uml.Communications;
// imports:
import org.w3c.dom.Element;

import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;
import edu.pku.sei.modeler.model.common.*;
import edu.pku.sei.modeler.model.core.*;
import edu.pku.sei.modeler.model.xml.XMLUtility;

import edu.pku.sei.modeler.model.uml.Ports.Port;

import edu.pku.sei.modeler.model.uml.Kernel.NamedElement;
import edu.pku.sei.modeler.uml.modelHelper.ModelPackage;

/**
 * @generated
 *
 */
public class Trigger extends NamedElement implements ITrigger {
	// attributes
	
	protected Event event;
	
	
	
	
	// references
	
	protected MetaTypedList port;
	
	
	
	// getters & setters for attributes
	
	public Event getEvent() {
		return event;
	}
	public void setEvent(Event newEvent) {
		Event oldevent = event;
		event = newEvent;
		firePropertyChange(ModelPackage.TRIGGER_EVENT, oldevent, newEvent);
	}
	
	// getters for references
	
	public MetaTypedList getPort() {
		if(port == null) {
			port = new MetaTypedList(Port.class, this, ModelPackage.TRIGGER_PORT);
		}
		return port;
	}
	
	// save & load
	public void serialize(Element root) {
		super.serialize(root);
		// attributes
		
		XMLUtility.xmlInstance.serializeNode(root, ModelPackage.TRIGGER_EVENT, event);
		
		// references
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.TRIGGER_PORT, port);		
		
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		// attributes
		
		event = (Event)XMLUtility.xmlInstance.deSerializeNode(root, ModelPackage.TRIGGER_EVENT, this);
		
		// references
		
		this.getPort().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.TRIGGER_PORT, this));
		
	}
	
	public void dynamicSet(String featureID, Object value) {
		if(featureID == null || "".equals(featureID)) {
			return;
		}
		// attributes
		
		else if(ModelPackage.TRIGGER_EVENT.equals(featureID)) {
			event = (Event)value;
		}
		
		// references
		
		else if(ModelPackage.TRIGGER_PORT.equals(featureID)) {
			getPort().add(value);
		}
		
		else
			super.dynamicSet(featureID, value);
	}
}
 
 
 
 
 